package com.hzlj.position.locate.common.dto.reportVideo;


import cn.hutool.core.util.ObjectUtil;
import com.fz.common.base.core.date.DateUtils;
import com.fz.common.base.enums.db.ResultField;
import com.fz.common.dict.annotation.Dict;
import com.hzlj.position.locate.common.enums.VideoStatus;
import com.hzlj.position.locate.common.model.ReportVideo;
import com.hzlj.position.locate.common.model.ReportVideoJzry;
import com.hzlj.sqjz.jz.common.dto.common.JzCommonQueryResultDTO;
import lombok.Data;
import lombok.ToString;
import lombok.experimental.Accessors;

import java.util.Date;

/**
 * 通信联络核查-人工核验(ReportInitiative)查询结果返回DTO
 *
 * @author lifh
 * @date 2023-03-13 19:22:32
 */
@Data
@ToString
@Accessors(chain = true)
public class ReportVideoWithJzJbxxDTO extends JzCommonQueryResultDTO {
    /**
     * 应核查时间
     */
    @ResultField(ReportVideo.class)
    private Date spotCheckTime;
    /**
     * 视频开始时间
     */
    @ResultField(ReportVideo.class)
    private Date videoStartTime;
    /**
     * 视频结束时间
     */
    @ResultField(ReportVideo.class)
    private Date videoEndTime;

    /**
     * 视频通话起止时间
     */
    @ResultField(ReportVideoJzry.class)
    private String videoStartEndTime;

    /**
     * 视频状态,dict-VIDEO_STATUS
     */
    @Dict("VIDEO_STATUS")
    @ResultField(ReportVideo.class)
    private String videoStatus;
    /**
     * 视频状态,dict-VIDEO_STATUS(文本)
     */
    private String videoStatusText;
    /**
     * 视频通话时长（毫秒）
     */
    @ResultField(ReportVideo.class)
    private Integer videoDuration;
    /**
     * 处理状态,dict-HANDLE_STATUS
     */
    @Dict("HANDLE_STATUS")
    @ResultField(ReportVideo.class)
    private String handleStatus;
    /**
     * 处理状态,dict-HANDLE_STATUS(文本)
     */
    private String handleStatusText;
    /**
     * 经度
     */
    @ResultField(ReportVideo.class)
    private String longitude;
    /**
     * 纬度
     */
    @ResultField(ReportVideo.class)
    private String latitude;
    /**
     * 上报位置
     */
    @ResultField(ReportVideo.class)
    private String reportAddress;
    /**
     * 点验通知是否发送成功
     */
    @ResultField(ReportVideo.class)
    private Boolean notice;
    /**
     * 点验通知是否发送失败原因
     */
    @ResultField(ReportVideo.class)
    private String noticeFailMsg;


    public String getVideoStartEndTime() {
        videoStartEndTime = "-";
        if (ObjectUtil.isNotEmpty(this.videoStartTime)) {
            videoStartEndTime = DateUtils.formatDate(this.videoStartTime) + videoStartEndTime;
        }

        if (ObjectUtil.isNotEmpty(this.videoEndTime)) {
            videoStartEndTime = videoStartEndTime + DateUtils.formatDate(this.videoEndTime);
        }
        return videoStartEndTime;
    }

    public String getVideoStatusTextAlias() {
        return (videoStatus.equalsIgnoreCase(VideoStatus.CALL.getStatus())
                || videoStatus.equals(VideoStatus.REJECT.getStatus())) ?
                "未接通" : "已接通";
    }


    public String getVideoDurationText() {
        int duration = this.videoDuration == null ? 0 : this.videoDuration;
        return DateUtils.formatDuration((long) (duration / 1000));
    }


}

